package com.example.endusation.controller;

import com.example.endusation.dto.UserInfoDTO;
import com.example.endusation.entity.UserInfoDO;
import com.example.endusation.service.LoginRegisterService;
import com.example.endusation.util.WrapperResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/core/web/auth")
public class LoginRegisterController {
    @Autowired
    private LoginRegisterService loginRegisterService;
    /**
     * 登录接口
     *
     * @param userInfoDTO
     * @return
     */
    @PostMapping("/sinin")
    public WrapperResponse login(@RequestBody UserInfoDTO userInfoDTO) throws Exception {

        WrapperResponse<UserInfoDO> wrapperResponse = loginRegisterService.login(userInfoDTO);
        return wrapperResponse;

    }

    /**
     * 注册接口
     *
     * @param userInfoDTO
     * @return
     */
    @PostMapping("/register")
    public WrapperResponse register(@RequestBody UserInfoDTO userInfoDTO) {
        return loginRegisterService.register(userInfoDTO);
    }
}
